#pragma once
#include <Windows.h>
#include "H264Docoder.h"
#include "CameraCapture.h"
extern "C"
{
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libavutil/avutil.h"
#include "libswscale/swscale.h"
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "sdl/SDL.h"
};

class SDLPlayser : public H264decoder::H264DecodeObserver , public Camera::CameraObserver{
public:
	SDLPlayser(HWND,int ,int, AVPixelFormat);
	~SDLPlayser();
	int RenderYuv(void *pBuf,uint32_t size, AVPixelFormat pix);
	int OnRecieveData(AVFrame *frame);
	int OnBuffer(double dblSampleTime, BYTE * pBuffer, long lBufferSize) ;
	int OnCameraData(uint8_t *dat, uint32_t size) ;
private:
	HWND mWindowWnd;
	//SDL---------------------------
	int screen_w = 0, screen_h = 0;
	int mInWidth, mInHeight;
	SDL_Texture* mTexture;
	SDL_Rect sdlRect;
	AVPixelFormat mFormat;
	SDL_Window *mScreen;
	SDL_Renderer *mRender;
};
